/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class Review
    {
    
        private String ASINField;

        private Decimal? ratingField;

        private Decimal? helpfulVotesField;

        private String customerIdField;

        private  Reviewer reviewerField;
        private Decimal? totalVotesField;

        private String dateField;

        private String summaryField;

        private String contentField;


        /// <summary>
        /// Gets and sets the ASIN property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ASIN")]
        public String ASIN
        {
            get { return this.ASINField ; }
            set { this.ASINField= value; }
        }



        /// <summary>
        /// Sets the ASIN property
        /// </summary>
        /// <param name="ASIN">ASIN property</param>
        /// <returns>this instance</returns>
        public Review WithASIN(String ASIN)
        {
            this.ASINField = ASIN;
            return this;
        }



        /// <summary>
        /// Checks if ASIN property is set
        /// </summary>
        /// <returns>true if ASIN property is set</returns>
        public Boolean IsSetASIN()
        {
            return  this.ASINField != null;

        }


        /// <summary>
        /// Gets and sets the Rating property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Rating")]
        public Decimal Rating
        {
            get { return this.ratingField.GetValueOrDefault() ; }
            set { this.ratingField= value; }
        }



        /// <summary>
        /// Sets the Rating property
        /// </summary>
        /// <param name="rating">Rating property</param>
        /// <returns>this instance</returns>
        public Review WithRating(Decimal rating)
        {
            this.ratingField = rating;
            return this;
        }



        /// <summary>
        /// Checks if Rating property is set
        /// </summary>
        /// <returns>true if Rating property is set</returns>
        public Boolean IsSetRating()
        {
            return  this.ratingField != null;

        }


        /// <summary>
        /// Gets and sets the HelpfulVotes property.
        /// </summary>
        [XmlElementAttribute(ElementName = "HelpfulVotes")]
        public Decimal HelpfulVotes
        {
            get { return this.helpfulVotesField.GetValueOrDefault() ; }
            set { this.helpfulVotesField= value; }
        }



        /// <summary>
        /// Sets the HelpfulVotes property
        /// </summary>
        /// <param name="helpfulVotes">HelpfulVotes property</param>
        /// <returns>this instance</returns>
        public Review WithHelpfulVotes(Decimal helpfulVotes)
        {
            this.helpfulVotesField = helpfulVotes;
            return this;
        }



        /// <summary>
        /// Checks if HelpfulVotes property is set
        /// </summary>
        /// <returns>true if HelpfulVotes property is set</returns>
        public Boolean IsSetHelpfulVotes()
        {
            return  this.helpfulVotesField != null;

        }


        /// <summary>
        /// Gets and sets the CustomerId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "CustomerId")]
        public String CustomerId
        {
            get { return this.customerIdField ; }
            set { this.customerIdField= value; }
        }



        /// <summary>
        /// Sets the CustomerId property
        /// </summary>
        /// <param name="customerId">CustomerId property</param>
        /// <returns>this instance</returns>
        public Review WithCustomerId(String customerId)
        {
            this.customerIdField = customerId;
            return this;
        }



        /// <summary>
        /// Checks if CustomerId property is set
        /// </summary>
        /// <returns>true if CustomerId property is set</returns>
        public Boolean IsSetCustomerId()
        {
            return  this.customerIdField != null;

        }


        /// <summary>
        /// Gets and sets the Reviewer property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Reviewer")]
        public Reviewer Reviewer
        {
            get { return this.reviewerField ; }
            set { this.reviewerField = value; }
        }



        /// <summary>
        /// Sets the Reviewer property
        /// </summary>
        /// <param name="reviewer">Reviewer property</param>
        /// <returns>this instance</returns>
        public Review WithReviewer(Reviewer reviewer)
        {
            this.reviewerField = reviewer;
            return this;
        }



        /// <summary>
        /// Checks if Reviewer property is set
        /// </summary>
        /// <returns>true if Reviewer property is set</returns>
        public Boolean IsSetReviewer()
        {
            return this.reviewerField != null;
        }




        /// <summary>
        /// Gets and sets the TotalVotes property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TotalVotes")]
        public Decimal TotalVotes
        {
            get { return this.totalVotesField.GetValueOrDefault() ; }
            set { this.totalVotesField= value; }
        }



        /// <summary>
        /// Sets the TotalVotes property
        /// </summary>
        /// <param name="totalVotes">TotalVotes property</param>
        /// <returns>this instance</returns>
        public Review WithTotalVotes(Decimal totalVotes)
        {
            this.totalVotesField = totalVotes;
            return this;
        }



        /// <summary>
        /// Checks if TotalVotes property is set
        /// </summary>
        /// <returns>true if TotalVotes property is set</returns>
        public Boolean IsSetTotalVotes()
        {
            return  this.totalVotesField != null;

        }


        /// <summary>
        /// Gets and sets the Date property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Date")]
        public String Date
        {
            get { return this.dateField ; }
            set { this.dateField= value; }
        }



        /// <summary>
        /// Sets the Date property
        /// </summary>
        /// <param name="date">Date property</param>
        /// <returns>this instance</returns>
        public Review WithDate(String date)
        {
            this.dateField = date;
            return this;
        }



        /// <summary>
        /// Checks if Date property is set
        /// </summary>
        /// <returns>true if Date property is set</returns>
        public Boolean IsSetDate()
        {
            return  this.dateField != null;

        }


        /// <summary>
        /// Gets and sets the Summary property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Summary")]
        public String Summary
        {
            get { return this.summaryField ; }
            set { this.summaryField= value; }
        }



        /// <summary>
        /// Sets the Summary property
        /// </summary>
        /// <param name="summary">Summary property</param>
        /// <returns>this instance</returns>
        public Review WithSummary(String summary)
        {
            this.summaryField = summary;
            return this;
        }



        /// <summary>
        /// Checks if Summary property is set
        /// </summary>
        /// <returns>true if Summary property is set</returns>
        public Boolean IsSetSummary()
        {
            return  this.summaryField != null;

        }


        /// <summary>
        /// Gets and sets the Content property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Content")]
        public String Content
        {
            get { return this.contentField ; }
            set { this.contentField= value; }
        }



        /// <summary>
        /// Sets the Content property
        /// </summary>
        /// <param name="content">Content property</param>
        /// <returns>this instance</returns>
        public Review WithContent(String content)
        {
            this.contentField = content;
            return this;
        }



        /// <summary>
        /// Checks if Content property is set
        /// </summary>
        /// <returns>true if Content property is set</returns>
        public Boolean IsSetContent()
        {
            return  this.contentField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetASIN()) {
                xml.Append("<ASIN>");
                xml.Append(EscapeXML(this.ASIN));
                xml.Append("</ASIN>");
            }
            if (IsSetRating()) {
                xml.Append("<Rating>");
                xml.Append(this.Rating);
                xml.Append("</Rating>");
            }
            if (IsSetHelpfulVotes()) {
                xml.Append("<HelpfulVotes>");
                xml.Append(this.HelpfulVotes);
                xml.Append("</HelpfulVotes>");
            }
            if (IsSetCustomerId()) {
                xml.Append("<CustomerId>");
                xml.Append(EscapeXML(this.CustomerId));
                xml.Append("</CustomerId>");
            }
            if (IsSetReviewer()) {
                Reviewer  reviewer = this.Reviewer;
                xml.Append("<Reviewer>");
                xml.Append(reviewer.ToXMLFragment());
                xml.Append("</Reviewer>");
            } 
            if (IsSetTotalVotes()) {
                xml.Append("<TotalVotes>");
                xml.Append(this.TotalVotes);
                xml.Append("</TotalVotes>");
            }
            if (IsSetDate()) {
                xml.Append("<Date>");
                xml.Append(EscapeXML(this.Date));
                xml.Append("</Date>");
            }
            if (IsSetSummary()) {
                xml.Append("<Summary>");
                xml.Append(EscapeXML(this.Summary));
                xml.Append("</Summary>");
            }
            if (IsSetContent()) {
                xml.Append("<Content>");
                xml.Append(EscapeXML(this.Content));
                xml.Append("</Content>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}